﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>自动计算</title>
    <script language="JavaScript" src="../../../Comm/JScript.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="../../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../../Comm/Gener.js"></script>
    <script type="text/javascript" language="javascript">
        //页面启动函数.
        $(function () {

            $("#Msg").html("正在加载,请稍后......");

            //组织主键, 
            var mypk = "AutoFull_" + GetQueryString("FK_MapData") + "_" + GetQueryString("KeyOfEn");
            var en = new Entity("BP.Sys.MapExt");
            en.MyPK = mypk;
            en.SetPKVal(mypk);

            var i = en.RetrieveFromDBSources(); //执行查询..
            if (i == 1)
                document.getElementById("Btn_Delete").disabled = false;

            document.getElementById("TB_Doc").value = en.Doc;
            $("#Msg").html("");

        });

        //装载模版.
        function LoadTemplate() {
            var url = "../../SettingTemplate.htm?TemplateType=AutoFull";
            WinOpen(url, 'ss');
        }

        function Save() {

            var doc = $("#TB_Doc").val();
            if (doc == null || doc == undefined || doc == "") {
                alert("请输入内容.");
                return;
            }

            doc = doc.replace("'", "~");

            $("#Msg").html("正在保存,请稍后......");

            //组织主键, 
            var mypk = "AutoFull_" + GetQueryString("FK_MapData") + "_" + GetQueryString("KeyOfEn");
            var en = new Entity("BP.Sys.MapExt");
            en.MyPK = mypk;
            en.RetrieveFromDBSources();

            en.SetValByKey("FK_MapData", GetQueryString("FK_MapData"));
            en.SetValByKey("AttrOfOper", GetQueryString("KeyOfEn"));
            en.SetValByKey("ExtType", "AutoFull");
            en.SetValByKey("Doc", doc);
            en.Save();

            window.location.href = window.location.href;
        }

        function Delete() {

            if (window.confirm('您确定要删除吗？') == false)
                return false;

            //组织主键, 
            var mypk = "AutoFull_" + GetQueryString("FK_MapData") + "_" + GetQueryString("KeyOfEn");
            var en = new Entity("BP.Sys.MapExt");
            en.MyPK = mypk;
            en.Delete(); //执行删除.

            window.location.href = window.location.href;
        }
    </script>
</head>
<body>
    <form id="cc">
    <table id="table" style="width: 95%;">
        <caption>
            自动计算表达式
        </caption>
        <tr>
            <td colspan="3" style="width: 95%;">
                <textarea rows="4" name="TB_Doc" id="TB_Doc"> </textarea>
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <input type="button" value="装载模版" onclick="LoadTemplate()" id="ddd" />
                <input type="button" value="保存" onclick="Save()" id="Btn_Save" />
                <input type="button" value="删除" onclick="Delete()" id="Btn_Delete" />
                <a href="javascript:ShowHidden('sqlexp')">填充表达式帮助:</a>
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <div id='sqlexp' style='color: Gray; display: none'>
                    <ul>
                        <li>1.如果是从表: 表达式就是列之间的计算，比如: @A;+@B; </li>
                        <li>2.如果是主表: 就是主表字段之间的计算,比如: @DanJia;*@ShuLiang; 或者 @单价*@数量 </li>
                    </ul>
                </div>
            </td>
        </tr>
    </table>


    <div id="Msg">
    </div>


    </form>
</body>
</html>
